package java101;

public abstract class GeoAngle implements HasMaxRange{

	protected double rad;
	
	//@return max range in degrees
	
	public abstract double getMaxRange();
	
	public GeoAngle(double rad) {
		if (Math.abs(rad) > getMaxRange())
			throw new IllegalArgumentException("Angle out of range");
		this.rad = Math.toRadians(rad);
	}
	
	public GeoAngle(int deg, int min, double sec) {
		this(deg + min / 60. + sec / 3600.);
	}

	public String toDMS(double latOrLong) {
		
		double latDeg = latOrLong;
		int deg  = (int) Math.floor(latDeg);
		latDeg = 60 * (latDeg - deg);
		int min = (int) Math.floor(latDeg);
		latDeg = latDeg - min;
		double sec = latDeg * 60;
		
		return String.format("%d\u00b0%d\'%.13f\"", deg, min, sec);
		
	}
	

	double getDeg() {
		return Math.toDegrees(this.rad);
	}
	
}

//MATH.ACOS!!!
//Inverse cosine ^

//public class Distance {
//static greatCircleDistance(GeoPoint 1, GeoPoint 2) {}
//}